<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>找到所有消失的数字</title>
</head>
<body>
  <script>
    function fn(nums) {
      const n = nums.length;
      for (const num of nums) {
        const x = (num - 1) % n
        nums[x] += n
      }
      const ret = [];
      for (const [i, num] of nums.entries()) {
        if (num <= n) {
          ret.push(i + 1)
        }
      }
      return ret
    }
    console.log(fn([4, 3, 2, 7, 8, 2, 3, 1]))
  </script>
</body>
</html>